package com.jettech.oa.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
 * 用户
 * 由于和JBPM的User冲突所以在使用hql查询User信息时需要在hql语句中加上User的全路径
 * @author Administrator
 *
 */
@Entity(name="com.jettect.oa.domain.User")
@Table(name="jettech_user")
public class User implements Serializable {
	private static final long serialVersionUID = 7215777440576659978L;
	private Long id;//主键
	private Role role;//所属的角色
	private Department department;//所属部门
	private String loginName;//登录帐号
	private String loginPassword;//登录密码
	private String realName;//真实姓名
	private String email;//邮箱
	private String status;//状态
	private Date createdTime;//创建时间
	private Date updatedTime;//更新时间
	private Date expiriedDate;//帐号失效时间
	
	public User(){
		
	}

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="user_id")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="role_id")
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="department_id")
	public Department getDepartment() {
		return department;
	}
	public void setDepartment(Department department) {
		this.department = department;
	}
	@Column(name="logig_name")
	public String getLoginName() {
		return loginName;
	}
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	@Column(name="logig_password")
	public String getLoginPassword() {
		return loginPassword;
	}
	public void setLoginPassword(String loginPassword) {
		this.loginPassword = loginPassword;
	}
	@Column(name="real_name")
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	@Column(name="email")
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Column(name="user_staus")
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name="created_time",updatable=false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatedTime() {
		return createdTime;
	}
	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	@Column(name="updateed_time")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getUpdatedTime() {
		return updatedTime;
	}
	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}
	@Column(name="expiried_date")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getExpiriedDate() {
		return expiriedDate;
	}
	public void setExpiriedDate(Date expiriedDate) {
		this.expiriedDate = expiriedDate;
	}
	public boolean equals(Object other){
		return EqualsBuilder.reflectionEquals(this, other);
	}
	public int hashCode(){
		return HashCodeBuilder.reflectionHashCode(this);
	}
	public String toString(){
		return ToStringBuilder.reflectionToString(this);
	}
}
